﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.ComponentModel;

namespace ESLReminder.Modules
{
    public abstract class GameModule : IPlugin
    {
        protected IReminderInterface m_Reminder;
        private PluginInfo m_PluginInfo;
        protected GameModule(PluginInfo info)
        {
            m_PluginInfo = info;
        }
        private bool m_Enabled = true;
        [DefaultValueAttribute(true)]
        public bool Enabled { get { return m_Enabled; } set { m_Enabled = value; } }
        public abstract string ProcessName { get; }
        public PluginInfo PluginInformation
        {
            get
            {
                return m_PluginInfo;
            }
        }
        public bool isGame(Process proc)
        {
            bool isGame = isGameInternal(proc);
            if (isGame)
            {
                m_Process = proc;
                m_Process.Exited += new EventHandler(m_Process_Exited);
            }
            return isGame;
        }

        void m_Process_Exited(object sender, EventArgs e)
        {
            //TODO: remove or do something useful
            //nothing yet
        }
        protected abstract bool isGameInternal(Process proc);
        public virtual void ProcessStarted(Process proc)
        {
            m_Process = proc;
        }
        protected Process m_Process;
        public Process Process
        {
            get
            {
                return m_Process;
            }
        }
        public void PluginInit(IPluginHost host)
        {
            m_Reminder = (IReminderInterface)host;
        }

        public virtual void OtherPluginLoaded(IPlugin plugin)
        {
            
        }
    }
}
